package com.tqjc.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tqjc.entity.SteelPlate;
import com.tqjc.entity.StockSteels;
import com.tqjc.entity.Task;
import com.tqjc.service.SteelPlateService;
import com.tqjc.service.StockSteelsService;
import com.tqjc.service.TaskService;
import com.tqjc.system.core.model.PageInfo;
import com.tqjc.system.core.query.QueryUtils;
import com.tqjc.system.core.util.ResponseUtil;
import com.tqjc.wrapper.SteelPlateWrapper;
import com.tqjc.wrapper.StockSteelsWrapper;
import com.tqjc.wrapper.TaskWrapper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@Controller
@RequestMapping("/task")
public class TaskController {

    @Resource
    TaskService taskService;



    //辊道管理主页
    @RequestMapping("/index")
    public String index() {
        return "xg5msteel/manage/TaskManage.html";
    }

    /**
     * 获取表格数据 树形结构
     *
     * @param
     * @param request
     * @return
     */
    @RequestMapping("/datagrid")
    @ResponseBody
    public void datagrid(Task task, PageInfo<Task> page, HttpServletRequest request, HttpServletResponse response) {
        //拼接查询条件
        QueryWrapper<Task> queryWrapper = QueryUtils.installQueryWrapperRow(task, request.getParameterMap());

        //执行查询
        IPage<Task> lstResult = taskService.page(page.getPageEntity(), queryWrapper);

        //结果处理,直接写到客户端
        ResponseUtil.write(response, new TaskWrapper(lstResult).wrap());
    }

}
